
import javax.microedition.lcdui.Graphics;

/**
 * 
 * @author hanying zheng
 *
 */
public class BrickLv2 {

	public int top;
	
	public int left;
	
	public int width;
	
	public int height;
	
	public int type;
	
	public final static int T_NORMAL = 1;
	
	public final static int T_FIXED = 2;
	
	public final static int T_HIDE = 3;
	
	private final int colors[] = new int[3];
	
	private final int frontColors[] = new int[3];
	
	public BrickLv2(int top, int left, int width, int height, int type) {
		this.height = height;
		this.left = left;
		this.top = top;
		this.width = width;	
		setType(type);
	}
	
	public final void setColor(int red, int green, int blue) {
		colors[0] = red >> 1;
		colors[1] = green >> 1;
		colors[2] = blue >> 1;
		frontColors[0] = red;
		frontColors[1] = green;
		frontColors[2] = blue;
	}

	public final void setType(int type) {
		this.type = type;
		if (type == T_NORMAL) {
			colors[0] = 118;
			colors[1] = 118;
			colors[2] = 118;
			frontColors[0] = 100;
			frontColors[1] = 100;
			frontColors[2] = 140;
		} else if (type == T_FIXED) {
			colors[0] = 100;
			colors[1] = 100;
			colors[2] = 30;
			frontColors[0] = 190;
			frontColors[1] = 200;
			frontColors[2] = 10;
		}
	}

	public void paint(Graphics g) {
		if (type == T_HIDE) {
			return;
		}
        g.setColor(0, 0, 0);
        g.fillRect(left + 2, top + 2, width, height);
        g.setColor(colors[0], colors[1], colors[2]);
        g.fillRect(left, top, width, height);
        g.setColor(frontColors[0], frontColors[1], frontColors[2]);
        g.fillRect(left + 1, top + 1, width - 1, height - 1);
    }
	
	
}
